<div class="form">
	<? if (!$this->form_no_flash): ?>
		<!--[if IE]><fieldset class="ie_fix"><![endif]-->
		<div class="formFlash" <? if ($this->form_flash_id): ?>id="<?= $this->form_flash_id ?>"<? endif ?>><?= flash() ?></div>
		<!--[if IE]></fieldset><![endif]-->
	<? endif ?>

	<? if ($form_has_tabs && !$this->form_report_layout_mode): ?>
		<div class="<?= $form_tabs_type ?>">
			<div class="scrollable-tabs" id="<?= $scroller_id = str_replace('.', '-', uniqid(get_class($form_model).'tab-scroller', true)) ?>">
				<div class="scrollable-tabs-outer">
					<div class="scrollable-tabs-inner">
						<ul id="<?= $this->formGetElementId('form_tabs', get_class($form_model)) ?>" class="<?= $form_tabs_type.'_tabs' ?>">
							<? 
								$index = 0;
								foreach ($form_elements as $tabCaption=>$elements): 
							?>
									<li <?= array_key_exists($tabCaption, $form_model->formTabIds) ? "id=\"".$form_model->formTabIds[$tabCaption]."\"" : null ?> class="round <?= $index == 0 ? 'active' : null ?> <?= (array_key_exists($tabCaption, $form_model->formTabVisibility) && !$form_model->formTabVisibility[$tabCaption]) ? 'hidden' : null ?>"><a href="#<?= 'tab_'.($index+1) ?>" onclick="return false"><?= h($tabCaption) ?></a>
									</li>
							<? 
								$index++;
								endforeach ?>
						</ul>
					</div>
				</div>
				<div class="clear tab_separator"></div>

				<div class="scroll-button left scroll-disabled">Scroll left</div>
				<div class="scroll-button right">Scroll right</div>
			</div>
		
			<ul id="<?= $this->formGetElementId('form_pages', get_class($form_model)) ?>" class="<?= $form_tabs_type.'_pages' ?>">
	<? endif ?>
		<? 
			$page_class = $this->form_preview_mode ? 'form_page_preview' : 'form_page';

			if ($this->form_report_layout_mode): 
		?>
			<table class="formReportLayout">
				<tr>
		<? 
			endif;
			
			$index = 0;
			$tab_num = count($form_elements);
			$width = round(100/$tab_num);
			foreach ($form_elements as $form_tab_caption=>$elements): 
				$css_class = array_key_exists($form_tab_caption, $form_model->formTabCssClasses) ? $form_model->formTabCssClasses[$form_tab_caption] : null;
		?>
				<? if ($this->form_report_layout_mode): ?>
					<td class="formReportColumn <?= $index == 0 ? 'first' : null ?> <?= $index == ($tab_num-1) ? 'last' : null ?>" style="width: <?= $width.'%' ?>">
						<div class="formReportColumnContent">
				<? else: ?>
					<? if ($form_has_tabs): ?><li class="<?= $css_class ?> <?= $page_class ?> <?= ($this->form_preview_mode && $index > 0 && !$this->form_report_layout_mode) ? 'hidden' : null ?>" id="<?= 'tab_'.($index+1) ?>"><? else: ?><div class="<?= $page_class ?>"><? endif ?>
				<? endif ?>
					
					<? if ($this->form_report_layout_mode): ?>
						<h3 class="formReportLayoutHeader"><?= h($form_tab_caption) ?></h3>
					<? endif ?>
					
					<? $this->formRenderPartial('form_tab', array('form_tab_caption'=>$form_tab_caption, 'form_tab_elements'=>$elements)) ?>
					<div  class="clear"></div>
				<? if ($this->form_report_layout_mode): ?>
						</div>
					</td>
				<? else: ?>
					<? if ($form_has_tabs): ?></li><? else: ?></div><? endif ?>
				<? endif ?>
		<? 
			$index++;
			endforeach ?>
			
		<? if ($this->form_report_layout_mode): ?>
				</tr>
			</table>	
		<? endif ?>
		
	<? if ($form_has_tabs && !$this->form_report_layout_mode): ?>
			</ul>
		</div>
		
		<script type="text/javascript">
			<? 
				if ($form_tabs_type == 'tabs'): 
					$trackTab = $this->viewDataElement('trackTab', true);
					$trackTab = $trackTab ? 'true' : 'false';
			?>
				window.addEvent('domready', function(){
					new TabManager('<?= $this->formGetElementId('form_tabs', get_class($form_model)) ?>', 
					  	'<?= $this->formGetElementId('form_pages', get_class($form_model)) ?>', 
					  	{trackTab: <?= $trackTab ?>});
					
					new Backend_ScrollabeTabbar('<?= $scroller_id ?>');
				});
				
			<? endif ?>
		</script>
	<? endif ?>
</div>
<div class="clear"></div>
<input name="edit_session_key" id="<?= $this->formGetElementId('form_session_key', get_class($form_model)) ?>" type="hidden" value="<?= $form_session_key ?>"/>
<input type="hidden" name="form_context" value="<?= $this->formGetContext() ?>"/>
<input type="hidden" name="form_unique_prefix" class="form_unique_prefix" value="<?= $this->formGetUniquePrefix() ?>"/>